wayland: Ensure we have a drop-side GdkDragContext without pointer
authorCarlos Garnacho <carlosg@gnome.org>
Thu, 19 Nov 2015 23:07:36 +0000 (00:07 +0100)
committerCarlos Garnacho <carlosg@gnome.org>
Thu, 19 Nov 2015 23:11:33 +0000 (00:11 +0100)
This GdkDragContext should be created even if we don't have pointer
capabilities. Make it created on add_seat(), and only set the device
on wl_seat.capabilities, so it can be set to either master pointer.

https://bugzilla.gnome.org/show_bug.cgi?id=741066

gdk/wayland/gdkdevice-wayland.c
gdk/wayland/gdkdnd-wayland.c
gdk/wayland/gdkprivate-wayland.h

index cce562e905cdccc31c2c1dd63fa8dc8d28d9ada4..74aba25493fd52043c3a56fcb5e03469061336d5 100644 (file)
@@ -2047,8 +2047,6 @@ seat_handle_capabilities (void                    *data,
       device_manager->devices =
         g_list_prepend (device_manager->devices, device->pointer);
 
-      device->drop_context = _gdk_wayland_drop_context_new (device->master_pointer,
-                                                            device->data_device);
       if (wayland_display->pointer_gestures)
         {
           device->wl_pointer_gesture_swipe =
@@ -2079,8 +2077,6 @@ seat_handle_capabilities (void                    *data,
       device_manager->devices =
         g_list_remove (device_manager->devices, device->pointer);
 
-      g_clear_object (&device->drop_context);
-
       g_signal_emit_by_name (device_manager, "device-removed", device->pointer);
       g_object_unref (device->pointer);
       device->pointer = NULL;
@@ -2181,6 +2177,11 @@ seat_handle_capabilities (void                    *data,
       device->touch_master = NULL;
       device->touch = NULL;
     }
+
+  if (device->master_pointer)
+    gdk_drag_context_set_device (device->drop_context, device->master_pointer);
+  else if (device->touch_master)
+    gdk_drag_context_set_device (device->drop_context, device->touch_master);
 }
 
 static void
@@ -2362,6 +2363,7 @@ _gdk_wayland_device_manager_add_seat (GdkDeviceManager *device_manager,
   device->data_device =
     wl_data_device_manager_get_data_device (display_wayland->data_device_manager,
                                             device->wl_seat);
+  device->drop_context = _gdk_wayland_drop_context_new (device->data_device);
   wl_data_device_add_listener (device->data_device,
                                &data_device_listener, device);
 
@@ -2394,6 +2396,7 @@ _gdk_wayland_device_manager_remove_seat (GdkDeviceManager *manager,
           wl_surface_destroy (device->pointer_surface);
           /* FIXME: destroy data_device */
           g_clear_object (&device->keyboard_settings);
+          g_clear_object (&device->drop_context);
           g_hash_table_destroy (device->touches);
           gdk_window_destroy (device->foreign_dnd_window);
           stop_key_repeat (device);
index 6f95b076a95d410767b41e05eb7d4ae12a354b80..70956868aa0d0a9962176dee48b247e265566148 100644 (file)
@@ -387,8 +387,7 @@ _gdk_wayland_window_drag_begin (GdkWindow *window,
 }
 
 GdkDragContext *
-_gdk_wayland_drop_context_new (GdkDevice             *device,
-                               struct wl_data_device *data_device)
+_gdk_wayland_drop_context_new (struct wl_data_device *data_device)
 {
   GdkWaylandDragContext *context_wayland;
   GdkDragContext *context;
@@ -397,8 +396,6 @@ _gdk_wayland_drop_context_new (GdkDevice             *device,
   context = GDK_DRAG_CONTEXT (context_wayland);
   context->is_source = FALSE;
 
-  gdk_drag_context_set_device (context, device);
-
   return context;
 }
 
index 5f8f37d12d657ae269d5a90b7240fb98b3541138..00db37f3b18d91acff04267eea4b21572dbedfb5 100644 (file)
@@ -104,8 +104,7 @@ void            _gdk_wayland_window_register_dnd (GdkWindow *window);
 GdkDragContext *_gdk_wayland_window_drag_begin (GdkWindow *window,
                                                GdkDevice *device,
                                                GList     *targets);
-GdkDragContext * _gdk_wayland_drop_context_new (GdkDevice             *device,
-                                                struct wl_data_device *data_device);
+GdkDragContext * _gdk_wayland_drop_context_new (struct wl_data_device *data_device);
 void _gdk_wayland_drag_context_set_source_window (GdkDragContext *context,
                                                   GdkWindow      *window);
 void _gdk_wayland_drag_context_set_dest_window (GdkDragContext *context,